Skip to content

agentcore: add native Anthropic API, direct CLI engine, Tern-style model gateway, and matrix evals - #390

Merged
d41sys merged 1 commit into
mainfrom
agentcore-backends
Dec 4, 2026
Merged

d41sys merged 1 commit into
mainfrom
agentcore-backends

Conversation

@d41sys

@d41sys d41sys commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

Completes the full multi-backend model-calling & CLI benchmarking stack across agentcore and evals/:

  1. Native Anthropic /v1/messages API in agentcore (agentcore/src/model.rs, agentcore/src/turn.rs):
    • Adds Api::Anthropic (explicit api: "anthropic" or URL auto-detection for api.anthropic.com / /anthropic).
    • Translates chat-shaped history to strictly alternating Anthropic Messages (grouping consecutive tool_result blocks into one user message), attaches cache_control: ephemeral on system prompt & last tool, maps effort to extended thinking budgets, and streams SSE (text_delta, thinking_delta, input_json_delta, cache-aware Tokens usage).
  2. Direct headless CLI engine in agentcore (agentcore/src/cli.rs, agentcore/src/main.rs):
    • agentcore cli <claude|codex|pi|omp|opencode> [program] [-- extra_args...] speaks the exact same Bate engine JSON-lines protocol (PROTOCOL.md) without requiring npm ACP adapters.
    • Parses NDJSON streams into Bate Events (Text, Thinking, ToolStart, ToolEnd, Usage, TurnEnd), preserves multi-turn session continuity (--resume / exec resume / --session), forwards Bate MCP connectors to claude --mcp-config, and cleanly kills the child process on Op::Abort.
  3. Tern-style local model gateway daemon (evals/gateway.py):
    • Loopback OpenAI-compatible HTTP proxy (/v1/chat/completions, /v1/responses, /v1/models, /health) + Unix control socket (serve + ctl status|stats|route|dump|stop).
    • Routes transparently to openai, anthropic, gemini, omp (omp auth-gateway stdio), cli, and mock backends while logging per-request latency & token usage to gateway_trace.jsonl.
  4. Unified multi-backend eval runner & leaderboard (evals/driver.py, evals/run.py, evals/analyze.py, evals/README.md):
    • Adds --api anthropic, --cli <kind>, --gateway <backend>, discover, gateway serve|ctl, matrix, and leaderboard (ranked pass@1 / pass^k + pairwise exact McNemar comparisons).

Evidence

  • cargo test -p agentcore:
    • 29 unit tests pass (incl. Anthropic Messages translation/SSE streaming and Claude/Codex/Pi CLI parsers)
    • 3 integration tests in agentcore/tests/backends.rs pass (end-to-end native Anthropic tool loop + headers, agentcore cli claude with --mcp-config & --resume, agentcore cli codex with exec resume)
    • 11 ACP tests + 94 engine tests + 12/12 harness scorecard pass
  • python3 -B -m unittest discover -s evals -v: 10/10 pass (incl. OpenAI↔Anthropic, OpenAI↔Gemini, live HTTP + Unix ctl socket lifecycle, and multi-backend leaderboard).
  • Verified evals/run.py discover and evals/run.py matrix --spec mock_a=mock --spec mock_b=mock end-to-end against compiled agentcore.
  • Full 4-step verification gate passed:
    • cd window/ui && npm ci && npm run build && npm test (147/147 pass)
    • cargo fmt --all --check
    • cargo clippy --workspace --all-targets --locked -- -D warnings
    • cargo test --workspace --locked

Merge Danger

  • Low. All existing Api::Chat, Api::Responses, and agentcore acp paths are untouched and continue passing all 94 engine + 11 ACP + 12 harness scorecard tests. New Api::Anthropic and agentcore cli modes are strictly opt-in.

Device decision

  • No installed app (/Applications/Bate.app) or user data (~/.bate) changes required; pure engine backend + local eval/gateway tooling.

@d41sys
d41sys merged commit 8cf2f7b into main Dec 4, 2026
5 checks passed
@d41sys
d41sys deleted the agentcore-backends branch December 4, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant